package hadoop.mr02;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class Partition_Mapper extends Mapper<LongWritable, Text, Text,Text> {
    Text t1 = new Text();
    Text t2 = new Text();

    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, Text>.Context context) throws IOException, InterruptedException {
        String[] split = value.toString().split(",");
        if(split[2].equals("性别")==false){
            String name = split[1];
            String JavaScore = split[3];
            String sex = split[2];
            t2.set(sex);
            String context_copy = name+"-"+sex+"-->java:"+JavaScore;
            t1.set(context_copy);
            // 对应分区类的 key,value
            context.write(t2,t1);
        }
    }
}
